package com.jw.controller;

import com.jw.common.ResultBean;
import com.jw.service.IMinioService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("/minio")
public class MinioController {

	private final Logger logger = LoggerFactory.getLogger(MinioController.class);

	@Autowired
	private IMinioService minioService;

	@PostMapping("/upload")
	public ResultBean<String> upload(@RequestParam("file") MultipartFile file) throws IOException {
		ResultBean<String> resultBean = new ResultBean<>();
		String objectName = minioService.uploadFile(file);
		resultBean.setData(objectName);
		return resultBean;
	}

}